﻿@model PagedList<RBS.Core.Model.D_Order>
@using RBS.Core.Extension
@using Webdiyer.WebControls.Mvc
@{
    ViewBag.Title = "我的订单";
    Layout = "~/Views/Shared/_UserLayout.cshtml"; 
}
<script>
    $(function () {
        $("#btnDelete").click(function () {
            var f_str = "";
            $(".ltable :checkbox[id='chkId']").each(function () {
                if (this.checked && this.value != "undefined") {
                    f_str += this.value + ',';
                }
            });
            $.dialog.confirm("删除记录后不可恢复，您确定吗？", function () {
                var url = '@Url.Action("AdminUserDelete")?ids=' + f_str;
                $.ajax({
                    url: url,
                    type: "post",
                    dataType: 'json',
                    success: function (data) {
                        if (data.IsSuccess) {
                            $.dialog.alert(data.Msg);
                            loadPage(data.Data);
                        }
                        else {
                            //  $("#msgtip").text(data.Msg);
                            $.dialog.alert(data.Msg);
                        }
                    }
                });
            });
            return false;
        });

    });
    function OrderDeed(id) {
        
    } 
function OrderCancel(id) {
    var url = '@Url.Action("OrderCancel")?ids=' + id;
    $.ajax({
        url: url,
        type: "post",
        dataType: 'json',
        success: function (data) {
            if (data.IsSuccess) {
                $.dialog.alert(data.Msg);
                loadPage(data.Data);

            }
            else {
                //  $("#msgtip").text(data.Msg);
                $.dialog.alert(data.Msg);
            }
        }
    });
}
</script>



<div class="content-tab-wrap">
    <div id="floatHead" class="content-tab">
        <div class="content-tab-ul-wrap">
            <ul>
                <li><a href="@Url.Action("OrderList")"  class="selected">我组织的饭局</a></li>
                <li><a href="@Url.Action("MyDinner")">我收到的邀请</a></li>
            </ul>
        </div>
    </div>
</div>

<div class="tbllist">
    <!--列表-->
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable">
        <tr>
            <th width="5%">序号</th>
            <th align="left" width="20%">预定酒店</th>
            <th align="left">就餐日期</th>
            <th align="left">预定时间</th>
            <th align="left">菜单金额</th>
            <th align="left">状态</th>
            <th align="left">邀请</th>
            <th width="18%">操作</th>
             <th >操作</th>
        </tr>
        @if (null != ViewData.Model)
        {
            var i = 0;
            foreach (var item in ViewData.Model)
            {
                i++;
            <tr>

                <td align="center">
                    @i
                </td>
                <td align="left">
                   @* http://localhost:61201/Store/HotelImg/60 *@
                    @Html.ActionLink(item.HotelName, "HotelImg", "Store", new { area = "", id = item.H_Id}, null)
                </td>
                <td align="left">
                    @Html.DisplayFor(modelItem => item.ReserveDate)<br/>@Html.DisplayFor(modelItem => item.ReserveTime)
                </td> 
                <td align="left">
                    @item.OrderTime.ToString("yyyy-MM-dd")
                </td> 
                <td align="left">
                    @(new RBS.Core.BLL.D_Order_Details().GetOrderMoney(item.Id))
                </td>
                <td align="left">
                    @Html.HtmlOrderStatus(item.OrderState)
                </td>
                <td align="left">
                    @{

                if (DateTime.Parse(item.ReserveDate + " " + item.ReserveTime) > DateTime.Now && item.OrderState == 2)
                {
                        @Html.ActionLink("邀请", "Invite", "Order", new { area = "User", orderid = item.Id }, null)
                }
                       
              }

                </td>
                <td align="center">
                    @{ 
                        if (DateTime.Parse(item.ReserveDate + " " + item.ReserveTime) > DateTime.Now)
                        {

                            switch (item.OrderState)
                            {
                                case (int)RBS.Common.RBSEnums.OrderStatus.Single:
                                    //下单
                                    @Html.ActionLink("[修改]", "SetOrder", "Yd", new { area = "", hotelid = item.H_Id, orderid = item.Id,type="edit"}, null)
                                    <a href="#" onclick=" OrderCancel(@item.Id) ">[取消]</a>
                                    break;
                                case (int)RBS.Common.RBSEnums.OrderStatus.Meal:
                                    @Html.ActionLink("[点菜]", "Index", "Store", new { area = "", id = item.H_Id, orderid = item.Id }, null)
                                    <a href="#" onclick=" OrderCancel(@item.Id) ">[取消]</a>
                                    //点餐
                                    break;
                                case (int)RBS.Common.RBSEnums.OrderStatus.Ok: 
                                    @Html.ActionLink("[修改]", "SetOrder", "Yd", new { area = "", hotelid = item.H_Id, orderid = item.Id,type="edit" }, null)
                                    @Html.ActionLink("[加菜]", "SetCookBook", "Yd", new { area = "", id = item.H_Id, orderid = item.Id,type="edit" }, null)
                                    <a href="#" onclick=" OrderCancel(@item.Id) ">[取消]</a>               
                                  @*  @Html.ActionLink("[使用优惠卷]", "OrderDeed", new {id=item.Id,hid = item.H_Id }, null)  *@
                                    //预定成功
                                    break;
                                case (int)RBS.Common.RBSEnums.OrderStatus.Canceled: 
                                    //订单取消
                                    break;
                                case (int)RBS.Common.RBSEnums.OrderStatus.Dining: 
                                @*   @Html.ActionLink("[使用优惠卷]", "OrderDeed", new {id=item.Id,hid = item.H_Id }, null)     *@
                                    //就餐
                                    break;
                                case (int)RBS.Common.RBSEnums.OrderStatus.ToComment:
                                    @Html.ActionLink("[点评]", "Index", "Store", new { area = "", id = item.H_Id }, null)
                                    break;
                                case (int)RBS.Common.RBSEnums.OrderStatus.Comment:
                                    @*  @Html.ActionLink("[查看]", "Detail", "Store", new { area = "", id = item.H_Id, orderid = item.Id }, null)  *@
                                    break; 
                            }
                        } 
                    }


                </td>
                <td>
                        @Html.ActionLink("查看", "Detail", "Store", new { area = "", id = item.H_Id, orderid = item.Id }, null)  
                </td>
            </tr>
            }
        }
    </table>
</div>
<!--/列表-->
<!--内容底部-->
<div class="line20">
</div>
<div class="pagelist">
    <div class="l-btns">
        <span>显示</span> <span>10 条/页</span><span>共 @Model.TotalPageCount 页 @Model.TotalItemCount 条记录，当前为第 @Model.CurrentPageIndex 页</span>
    </div>
    @Html.Pager(Model, new PagerOptions { PageIndexParameterName = "id", ShowPageIndexBox = true, PageIndexBoxType = PageIndexBoxType.DropDownList, ShowGoButton = false, CurrentPagerItemWrapperFormatString = "<span class=\"current\">{0}</span>" }, new { id = "PageContent", @class = "default" })
    @section Scripts{@{Html.RegisterMvcPagerScriptResource();}}
</div>
<!--/内容底部-->


